# @Time    : 2021/1/19 14:55
# @Author  : LDY
# @Email   : 274884591@qq.com
# @File    : orderSuite.py
# @desc    : 执行套件
# @Software: PyCharm
import time
import unittest

from BeautifulReport import BeautifulReport
from Base.SendEmail import getReportAddress, send_email
from Config.Config import Dir

filename = 'TestReport_OrderTreasure' + time.strftime('%Y%m%d_%H%M%S', time.localtime())
description = '订货宝GUI自动化测试'
# 匹配模式
pattern = "test*.py"
# 实例化套件对象
test_suite = unittest.TestSuite()

testcase = unittest.TestLoader().discover(Dir.TestGUIPath, pattern=pattern)
# 添加用例到套件内
test_suite.addTests(testcase)
# 执行套件
result = BeautifulReport(test_suite)
result.report(filename=filename, description=description, report_dir=Dir.OrderReport)

# 发送邮件
# 查找最新生成的测试报告
new_report_addr = getReportAddress(Dir.OrderReport)
# 自动发送邮件
TO = ['1308756861@qq.com', '274884591@qq.com', '125414887@qq.com', '1418204211@qq.com']
send_email(new_report_addr, TO)
